import React, { Component } from "react";

export default class App extends Component {
  myRef = React.createRef();
  render() {
    return (
      <div>
        <input type="text" ref={this.myRef} />
        <button
          style={{ marginLeft: "10px" }}
          onClick={() => {
            console.log(this.myRef.current.value);
          }}
        >
          点击获取input值
        </button>
      </div>
    );
  }
}
